<%@ page import="j.framework.core.FApplication" %>
<%@ page import="j.framework.base.service.ApplicationService" %>
<%@ page import="j.util.SpringBeans" %>
<%@ page import="j.framework.core.Dict" %>
<%@ page import="java.util.List" %>
<%@ page import="j.util.New" %>
<%@ page import="j.framework.core.DictItem" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="st" tagdir="/WEB-INF/tags" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="j" uri="j/tags" %>
<%@ taglib prefix="joyi" uri="http://www.joyi.cn/tags"%>

<%
    ApplicationService service = SpringBeans.getBean(ApplicationService.class);
    List<Dict> list = service.getDictionaries();
    List<DictItem> items = New.list(list.size());
    for(Dict d : list){
        DictItem item = new DictItem();
        item.setName(d.getName());
        item.setCode(d.getCode());
        items.add(item);
    }
    request.setAttribute("dictionaryList",items);
%>

<st:form action="?act=savefm" formId="frmQueryField">
    <div data-options="region:'center'">
            <input type="hidden" name="queryId" value="${p.queryId}"/>
            <input type="hidden" name="isTree" value="${isTree}"/>
        <table class="data">
            <thead>
            <tr>
                <th>表别名</th>
                <th>字段名称</th>
                <th>作为key</th>
                <th>显示名称</th>
                <th>显示名称TAG</th>
                <th>宽度</th>
                <th style="width:80px;">数据类型</th>
                <th style="width:80px;">配置footer</th>
                <th>主键</th>
                <c:if test="${isTree}">
                    <th>树字段</th>
                    <th>树父字段</th>
                </c:if>
                <th>是否隐藏</th>
                <th>支持排序</th>
                <th>默认排序</th>
                <th style="width:80px;">排序方向</th>
                <th>显示顺序</th>
                <th style="width:80px;">格式化类型</th>
                <th style="width:80px;">格式化选项</th>
                <th style="width:80px;">字典选择</th>
                <th style="width:80px;">对齐方式</th>
            </tr>
            </thead>
            <c:forEach items="${list}" var="item">
                <tr>
                    <td>
                        <input type="text" name="${item.fieldId}_tableAliasName"  value="${item.tableAliasName}" style="width:40px;"/>
                    </td>
                    <td><b>${item.tableAliasName}</b>.${item.fieldName}</td>
                    <td>
                        <input type="checkbox" name="${item.fieldId}_usedFieldNameAsKey" value="1" <c:if test="${item.usedFieldNameAsKey}">checked</c:if> />
                    </td>
                    <td>
                        <input type="text" name="${item.fieldId}_displayName"  value="${item.displayName}" style="width:80px;"/>
                    </td>
                    <td>
                        <input type="text" name="${item.fieldId}_displayNameTag"  value="${item.displayNameTag}" style="width:80px;"/>
                    </td>
                    <td>
                        <input type="number" name="${item.fieldId}_width"  value="${item.width}" style="width:36px;"/>
                    </td>
                    <td>
                        <joyi:select name="${item.fieldId}_dataType" code="DICT2014070115563301" selectedValue="${item.dataType}"/>
                    </td>
                    <td>
                        <a href="javascript:j.open('/user/pd?act=jsp&queryId=${p.queryId}&feildid=${item.fieldId}&jsp=<j:des data="qmd/queryFieldFooters"/>','editFooter',null,600,500);">footer定义</a>
                    </td>
                    <td>
                        <input type="checkbox" name="${item.fieldId}_primaryKey" value="1" <c:if test="${item.primaryKey}">checked</c:if> />
                    </td>
                    <c:if test="${isTree}">
                        <td>
                            <input type="radio" name="treeFieldId" value="${item.fieldId}" <c:if test="${item.asTreeField}">checked</c:if>/>
                        </td>
                        <td>
                            <input type="radio" name="treeParentFieldId" value="${item.fieldId}" <c:if test="${item.asTreeParentField}">checked</c:if>/>
                        </td>
                    </c:if>
                    <td>
                        <input type="checkbox" name="${item.fieldId}_suppressible" value="1" <c:if test="${item.suppressible}">checked</c:if> />
                    </td>
                    <td>
                        <input type="checkbox" name="${item.fieldId}_sortSupported" value="1" <c:if test="${item.sortSupported}">checked</c:if> />
                    </td>
                    <td>
                        <input type="checkbox" name="${item.fieldId}_defaultSort" value="1" <c:if test="${item.defaultSort}">checked</c:if> />
                    </td>
                    <td>
                        <joyi:select name="${item.fieldId}_defaultSortOrder" code="DICT2014070115563303" selectedValue="${item.defaultSortOrder}"/>
                    </td>
                    <td>
                        <input type="number" name="${item.fieldId}_displayOrder"  value="${item.displayOrder}" style="width:36px;"/>
                    </td>
                    <td>
                        <joyi:select name="${item.fieldId}_formatType" code="DICT2014070115563305" selectedValue="${item.formatType}" theFirstItemText=""/>
                    </td>
                    <td>
                        <input type="text" name="${item.fieldId}_formatOptions"  value="${item.formatOptions}" style="width:80px;"/>
                    </td>
                    <td>
                        <joyi:select name="${item.fieldId}_dictionaryId" items="${dictionaryList}"  selectedValue="${item.dictionaryId}"/>
                    </td>
                    <td>
                        <joyi:select name="${item.fieldId}_columnDataAlign" code="DICT2014070115563302" selectedValue="${item.columnDataAlign}"/>
                    </td>
                </tr>
            </c:forEach>
        </table>
    </div>
    <script>
        function doBeforeSave(frm){
            return window.confirm("确认要保存本次修改吗？");
        }
    </script>
</st:form>